#!/usr/bin/python
# -*- coding: UTF-8 -*-
# @author:qiaofinn
# @file:serializers.py
# @time:2020/09/10

from rest_framework import serializers
from apps.adorn_service.models import OrderService, AdornService


class AdornServiceAppSeializer(serializers.ModelSerializer):
    image = serializers.SerializerMethodField()
    describe_note = serializers.SerializerMethodField()

    def get_describe_note(self, obj):
        return obj.describe[:20]

    def get_image(self, obj):
        if obj.image:
            return obj.image.get_url()
        return ''

    class Meta:
        model = AdornService
        fields = '__all__'


class OrderAppServiceSerializer(serializers.ModelSerializer):
    class Meta:
        model = OrderService
        fields = '__all__'
